﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DedicatedKeyGenerator.Model;
using Xtensive.Orm;
using Xtensive.Orm.Configuration;

namespace DedicatedKeyGenerator
{
    class Program
    {
        static void Main(string[] args)
        {
            // Loading domain configuration section with name "Default".
            var domainConfiguration = DomainConfiguration.Load("Default");
            var domain = Domain.Build(domainConfiguration);

            using (var session = domain.OpenSession()) {
                using (var t = session.OpenTransaction()) {

                    // Provide hierarchy root class with dedicated key generator info, see Model.cs
                    // Now both hierarchies have 2 separate key sequences

                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));
                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));
                    Console.WriteLine(Key.Generate<Customer>(session));
                    Console.WriteLine(Key.Generate<Product>(session));

                    t.Complete();
                }
            }
        }
    }
}
